import http from '@/utils/http'

interface BasicParams {
    dtoName: string // 参考后端接口文档
    queryId: string // 参考confluence上的页面需求SQL标识
    version: string // 参考confluence上的页面需求SQL版本号
    menuName: string // 菜单的标识，与菜单管理配置保持一致
    usage: string // 接口后缀，标识用途
}
/*
  eg./ims-tworkgz-service/viewCstHistory/getCstHistory
*/

/** 获取 EQ Id信息 */
export function getEqpId({ lineId, shopId, reasonCodeType }: { lineId: string, shopId: string, reasonCodeType: string }): Promise<any> {
  const data = {
    detailMachineType: 'UNIT',
    dtoName: 'ChangeGlassGradeEqpIdDTO',
    version: '80039',
    queryId: 'GetMachineList',
    lineId,
    reasonCodeType,
    shopId

  }
  return http.request({
    url: '/ims-tworkgz-service/changeGlassGrade/getEqpId',
    method: 'POST',
    data
  })
}

/** 获取 grade信息 */
export function getGradeList({
  shopId, site, cstId, operation, operationVer, version
}: { shopId: string, site: string, cstId: string, operation: string, operationVer: string, version: string }): Promise<any> {
  const data = {
    dtoName: 'GradeDTO',
    gradeType: 'Lot',
    queryId: 'GetGradeList',
    version,
    cstId,
    operation,
    operationVer,
    shopId,
    site
  }
  return http.request({
    url: '/ims-tworkgz-service/changeGlassGrade/getGradeList',
    method: 'POST',
    data
  })
}

/** 获取 LineId信息 */
export function getLineId({
  bayId, reasonCodeType, shopId
}: { bayId: string, reasonCodeType: string, shopId: string }): Promise<any> {
  const data = {
    detailMachineType: 'MAIN',
    dtoName: 'ChangeGlassGradeLineIdDTO',
    queryId: 'GetMachineList',
    version: '80075',
    bayId,
    reasonCodeType,
    shopId
  }
  return http.request({
    url: '/ims-tworkgz-service/changeGlassGrade/getLineId',
    method: 'POST',
    data
  })
}

/** 获取 Operation信息 */
export function getOperation({
  lineId, reasonCodeType, shopId
}: { lineId: string, reasonCodeType: string, shopId: string }): Promise<any> {
  const data = {
    dtoName: 'ChangeGlassGradeOperationDTO',
    lineId,
    queryId: 'GetProcessOperationList',
    reasonCodeType,
    shopId,
    version: '80010'
  }
  return http.request({
    url: '/ims-tworkgz-service/changeGlassGrade/getOperation',
    method: 'POST',
    data
  })
}

/** 获取 ReasonCode信息 */
export function getReasonCode({ reasonCodeType, shopId, superReasonCode }: { reasonCodeType: string, shopId: string, superReasonCode:string }): Promise<any> {
  const data = {
    dtoName: 'ChangeGlassGradeReasonCodeDTO',
    queryId: 'GetReasonCodeList',
    version: '80019',
    reasonCodeType,
    shopId,
    superReasonCode
  }
  return http.request({
    url: '/ims-tworkgz-service/changeGlassGrade/getReasonCode',
    method: 'POST',
    data
  })
}

/** 获取 ReasonCodeType信息 */
export function getReasonCodeTypeList({ operationType }: { operationType: string }): Promise<any> {
  const data = {
    dtoName: 'ChangeGlassGradeReasonCodeTypeDTO',
    queryId: 'GetReasonCodeTypeList',
    version: '80001',
    operationType
  }
  return http.request({
    url: '/ims-tworkgz-service/changeGlassGrade/getReasonCodeTypeList',
    method: 'POST',
    data
  })
}

/** 获取 SuperReasonCode信息 */
export function getSuperReasonCode({ reasonCodeType, shopId }: { reasonCodeType: string, shopId: string }): Promise<any> {
  const data = {
    dtoName: 'ChangeGlassGradeSuperReasonCodeDTO',
    queryId: 'GetReasonCodeList',
    version: '80018',
    reasonCodeType,
    shopId
  }
  return http.request({
    url: '/ims-tworkgz-service/changeGlassGrade/getSuperReasonCode',
    method: 'POST',
    data
  })
}
